package dm.ast.fix;

import dm.ast.DmQuery;
import dm.ast.DmSelect;

/*
 * @ 2023-08-29
 *根据执行错误，简单修正sql，尽量使sql执行成功
 */
public class FixRunError {
    //返回值表示sql是否被修正
    public static boolean fixErrors(DmSelect s, int errcode) {
        boolean flag = false;
        switch (errcode) {
//-4097|单行子查询返回多行
            case -4097:
                s.fixErr4097();
                flag = true;
                break;
            default:
                break;
        }
        return flag;
    }

    public static boolean fixQueryErrors(DmQuery dmQuery, int errcode) {
        boolean flag = false;
        switch (errcode) {
//-4097|单行子查询返回多行
            case -4097:
                for (DmSelect s:dmQuery.querySelects){
                    s.fixErr4097();
                }
                flag = true;
                break;
            default:
                break;
        }
        return flag;
    }
}
